//
//  SendToolBar.m
//  新浪微博
//
//  Created by hbl on 16/3/1.
//  Copyright © 2016年 hbl. All rights reserved.
//

#import "SendToolBar.h"
@implementation SendToolBar

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"compose_toolbar_background_os7"]];
    }
    return self;
}

- (void)addToolButtonWithImageName:(NSString *)imageName selImageNmae:(NSString *)selImageNmae
{
    UIButton *btn = [[UIButton alloc]init];
    [btn setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed:selImageNmae] forState:UIControlStateHighlighted];
    [btn addTarget:self action:@selector(onClick:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:btn];
   
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat btnW = self.bounds.size.width/self.subviews.count;
    for (int i = 0; i<self.subviews.count; i++) {
        UIButton *btn = self.subviews[i];
        btn.tag = i;
        btn.frame = CGRectMake(btnW * i, 0, btnW, self.bounds.size.height);
        
    }
}

- (void)onClick:(UIButton *)btn
{
    if ([self.delegate respondsToSelector:@selector(sendToolBarClickBtn:)]) {
        [self.delegate sendToolBarClickBtn:btn];
    }
}

@end
